package GUI;

import Control.Character;
import Control.CommonWord;
import processing.core.PImage;


class CommonWordsButton extends Component
{
	TagCloud tc;
	Character c;
	public boolean selected =false;
	public boolean pressed;
	////////////////////////////////////////////////////////////////////////////////////////////////////
	public CommonWordsButton(Character ci)
	{
		width = 205;
		height = 25;
		c=ci;
		tc = new TagCloud(this);
	}
	public void setLabel(String name)
	{
		label = name;

	}
	public void draw()
	{

		int cx = x;
		int cy = y;

		if(label != null)
		{
			Utils.globalProcessing.textAlign(Utils.globalProcessing.LEFT);
			width = (int)(Utils.globalProcessing.textWidth(label)) + 10;
			if(mouseOver()) 
			{
				super.draw();
				if(Utils.globalProcessing.mousePressed)
				{

					Utils.gu.drawVGradient(x, y + height, width, -height, Utils.globalProcessing.color(150, 150, 180), 80, Utils.globalProcessing.color(150, 150, 180), 255, (float)0.8);    
					Utils.gu.drawBox(x, y, width, height, 0, Utils.globalProcessing.color(150, 150, 200), 255);
					Utils.gu.drawBox(x, y, width, height, 1, Utils.globalProcessing.color(150, 150, 200), 150);

					cx += 2;
					cy += 2;
					pressed = true;


				}
				else if(pressed)
				{
					
					pressed = false;
					if(selected){
						selected = false;
						Utils.tagCloudActive=false;
					}
					else {selected = true;
					Utils.tagCloudCWB = this;
					Utils.tagCloudActive=true;
					}
				}


			}
			else
			{
				pressed = false;
			}

			Utils.globalProcessing.strokeWeight(1);
			Utils.globalProcessing.fill(255);

			Utils.globalProcessing.textFont(Utils.plotFont, 13);
			Utils.globalProcessing.text(label, cx + 5, cy + 15);


		}
	}
	//Draws on the screen common words for the character
	public static void drawCommonWords(Character c){
		
			Utils.tagCloudCWB.tc.draw();
			Utils.globalProcessing.textFont(Utils.plotFont, 19);
			Utils.globalProcessing.stroke(128);
			Utils.globalProcessing.strokeWeight(2);
		

	}

	////////////////////////////////////////////////////////////////////////////////////////////////////
	PImage icon;
	String label;
}

